<template>
  <div>
    <BasicTable @register="registerTable">

      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'action'">
          <TableAction :actions="[
            {
              icon: 'clarity:note-edit-line',
              onClick: handleEdit.bind(null, record),
            },
            // {
            //   icon: 'ant-design:delete-outlined',
            //   color: 'error',
            //   popConfirm: {
            //     title: '是否确认删除',
            //     placement: 'left',
            //     confirm: handleDelete.bind(null, record),
            //   },
            // },
          ]" />
        </template>
      </template>
    </BasicTable>
    <MenuDrawer @register="registerDrawer" @success="handleSuccess" />
  </div>
</template>
<script lang="ts" setup>
import { nextTick, onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import { approvalSettingList, approvalSettingDelete } from '@/api/sys/approval';
import { useDrawer } from '@/components/Drawer';
import MenuDrawer from './MenuDrawer.vue';
import { columns, searchFormSchema } from './menu.data';
import { useGo } from '@/hooks/web/usePage';

defineOptions({ name: 'MenuManagement' });
const go = useGo();

const [registerDrawer, { openDrawer }] = useDrawer();
const [registerTable, { reload, setTableData }] = useTable({
  title: '审批设置列表',
  api: approvalSettingList,
  columns,
  formConfig: {
    labelWidth: 120,
    schemas: searchFormSchema,
    autoSubmitOnEnter: true,
  },
  useSearchForm: true,
  showTableSetting: true,
  bordered: true,
  handleSearchInfoFn(info) {
    console.log('handleSearchInfoFn', info);
    return info;
  },
  actionColumn: {
    width: 120,
    title: '操作',
    dataIndex: 'action',
  },
});



function handleCreate() {
  openDrawer(true, {
    isUpdate: false,
  });
}

function handleEdit(record: Recordable) {
  // openDrawer(true, {
  //   record,
  //   isUpdate: true,
  // });
  // go('/system/approvalLine/' + record.approvalSettingId);
  go({
    path: `/system/approvalLine/${record.approvalSettingId}`, query: { approvalSettingId: record.approvalSettingId }
  })
}

function handleDelete(record: Recordable) {

}

function handleSuccess() {
}


</script>
